package com.ruoyi.camp.api;


import com.ruoyi.camp.domain.CActivity;
import com.ruoyi.camp.domain.WxActivity;
import com.ruoyi.camp.service.ICActivityService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "营地活动管理", tags = {"营地活动管理"})
@RestController
@RequestMapping("/wechat/activity")
public class WxActivityController extends BaseController {
    @Autowired
    private ICActivityService ActivityService;

    @ApiOperation(value = "根据营地Id获取该营地下的活动列表", response = WxActivity.class)
    @GetMapping("/getInfoByCampId/{campId}")
    public AjaxResult getInfoByCampId(@PathVariable("campId") String campId) {
        if (campId == null) {
            return error("营地Id不能为空");
        }
        List<CActivity> list = ActivityService.getInfoByCampId(campId);
        return success(list);
    }
    @ApiOperation(value = "添加活动并提交审批")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody CActivity cActivity){
        if (cActivity == null) {
            return error("数据不能为空");
        }
        if (cActivity.getCampId() == null) {
            return error("营地Id不能为空");
        }
        if (cActivity.getActivityName() == null) {
            return error("活动名称不能为空");
        }
        if (cActivity.getOriginalPrice() == null) {
            return error("原价不能为空");
        }
        return toAjax(ActivityService.insertCActivity(cActivity));
    }
    @DeleteMapping("/{activityIds}")
    public AjaxResult remove(@PathVariable String[] activityIds)
    {
        return toAjax(ActivityService.deleteCActivityByActivityIds(activityIds));
    }
}
